# -*- coding: utf-8 -*-
__author__ = 'Administrator'

import config
from config import cfg

Arginit = {"Msg":u"","IP":"192.168.1.106"}
def SaveBaseArgs(initdict):
    Arginit = initdict
    global cfg
    cfg.set("Set","msg",Arginit["Msg"].encode("utf-8"))
    cfg.set("Set","hz",Arginit["Hz"].encode("utf-8"))
    cfg.set("Set","ip",Arginit["IP"])
    config.renew_cfg(cfg)

def Init(cfg,args):
    name = "Set"
    if cfg.has_section(name):
        print("有了 [Set] 了!")
        pass
    else:
        #print(u"没有 [Set] !!现在开始写入:")
        cfg.add_section(name)
        cfg.set(name,"msg",args["Msg"].encode("utf-8"))
        cfg.set(name,"msg",args["Hx"].encode("utf-8"))
        cfg.set(name,"ip",args["IP"])
        config.renew_cfg(cfg)
        #print("[Trace] 写入完成")
    #end if else
    return cfg
#end def

def GetBaseArgs():
    Msg      = cfg.get("Set","msg").decode("utf-8")
    Hz      = cfg.get("Set","hz").decode("utf-8")
    IP      = cfg.get("Set","ip")

    return {"Msg":Msg,"Hz":Hz,"IP":IP}
# end def

cfg = Init(cfg,Arginit)
